package com.xaicode.template.sqlite3.serviceimpl;

import cn.hutool.core.util.RandomUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xaicode.template.sqlite3.entity.Airport;
import com.xaicode.template.sqlite3.mapper.AirportMapper;
import com.xaicode.template.sqlite3.service.IAirportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author xiachangjian <xiachangjian@sataero.cn>
 * @date 2023/1/29
 * @since v2.0.1
 */
@Slf4j
@Service
@DS("base")
public class AirportServiceImpl extends ServiceImpl<AirportMapper, Airport> implements IAirportService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void addOne() {
        Airport airport = new Airport();
        airport.setName(RandomUtil.randomString(6));
        save(airport);
        log.info("airport add [{}]", airport.getId());
    }
}
